The present invention relates to database accessing schemes and more particularly to methods for providing a concurrent access to a cache having exclusive access to a database.
In highly concurrent systems it is often desirable to cache parts of the database in a middle tier. This capability is often provided by an object/relational (O/R) engine, which as well as caching, also provides an object model on top of the relational data model. As with any caching architecture, the goal is to off-load a central resource, and provide data access in the middle tier without overly burdening the database.
One of the ways to relieve the burden on the database is to specify that the cache has exclusive access to the database for a certain period of time. This exclusivity constraint means that the only way to modify the underlying database entity is via the cache. Given this constraint, it is then possible to know the value of the entity in the database by looking at the value in the cache. That is, the value can be obtained from the cache without reading from the database.
Although it is commonplace to have such an exclusive caching architecture, it often comes with a serializability constraint. That is, it is assumed that there exists only a single copy of the cached object. This single-copy limitation reduces the effective throughput of the system because it means that only one transaction can use the copy at a time. That is, transactions must be serialized to be able to use exclusive access caches.
The standard practice is to allow only a single exclusive mode copy of a given object to exist. That is, the first transaction to access the object xe2x80x9cownsxe2x80x9d the object, and other transactions must wait for this first transaction to release the object. If higher concurrency is needed, typically the exclusivity constraint is dropped. That means that any number of transactions can access the entity, but they will all have to read the state of the object from the database. In other words, the caching aspect is disabled.
What is needed in the art is a methodology which permits the exclusivity constraint to be upheld while still allowing for concurrent access to entities. The present invention satisfies this and other needs.
The invention can be characterized as providing in a data store having an exclusive access cache, a method for permitting concurrent access to an object in the data store, comprising the steps of:
a. responding to a first transaction by retrieving a cache version of the object from the exclusive access cache;
b. responding to any concurrent transactions by retrieving respective new instances of the object from the data store;
c. completing any current transactions by selectively committing any updates that were made to the object with a write operation to the data store; and
d. completing a last transaction by selectively committing any updates that were made to the object with a write to the data store and a deposit to the exclusive access cache, the last transaction being either the first transaction or one of the concurrent transactions, if any.
The invention can be further characterized as a method as above, including the additional steps of:
tracking the number of new instances of the object that have been retrieved; and
decrementing the number of new instances of the object as each concurrent transaction is completed.
If the number of new instances is tracked, the invention can be further characterized as having step (d) performed when the number of new instances is zero.
These and other steps, features, aspects, and advantages of the invention will be apparent from the accompanying Drawings and Drawing Descriptions and the Detailed Description of Certain Preferred Embodiments.